package com.web.portal.controller.portal;

import com.web.portal.controller.admin.ActivityAdminApi;
import com.web.portal.pojo.query.ActivityQuery;
import com.web.portal.response.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "活动查看")
@Slf4j
@RestController
@RequestMapping("/activity")
public class ActivityController {

    @Autowired
    private ActivityAdminApi activityAdminApi;

    /**
     * 用id获取活动
     *
     * @param activityId
     * @return
     */
    @ApiOperation(value = "用id获取活动和参与用户")
    @GetMapping("/activity_and_user/{activityId}")
    public ResponseResult getActivityAndUser(@PathVariable("activityId") String activityId) {
        return activityAdminApi.getActivityAndUser(activityId);
    }

    /**
     * 用ActivityCode获取活动
     *
     * @param activityCode
     * @return
     */
    @ApiOperation(value = "用id获取活动和参与用户")
    @GetMapping("/activity_and_user_bycode/{activityCode}")
    public ResponseResult getActivityAndUserByActivityCode(@PathVariable("activityCode") String activityCode) {
        return activityAdminApi.getActivityAndUserByActivityCode(activityCode);
    }

    //3 条件查询带分页
    @ApiOperation(value = "条件查询带分页")
    @PostMapping("/findPage_activity/{current}/{limit}")
    public ResponseResult findActivity(@PathVariable long current,
                                       @PathVariable long limit,
                                       @RequestBody(required = false) ActivityQuery activityQuery) {
        return activityAdminApi.findPageActivitys(current, limit, activityQuery);
    }
}
